package com.hongawen.dynamic;

import lombok.Data;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @author hongawen
 * @version 1.0.0
 * @date 2021年08月16日 11:50
 */
@Data
public class DynamicBean {

    private  InvocationHandler invocationHandler;

    {
        invocationHandler = new InvocationHandler() {
            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                System.out.println(method.getName());
                if (method.getName().equals("hello")) {
                    System.out.println("Good morning, " + args[0]);
                }else  if (method.getName().equals("springHello")) {
                    System.out.println("Good morning,Spring, " + args[0]);
                }else  if (method.getName().equals("summerHello")) {
                    System.out.println("Good morning,Summer, " + args[0]);
                }
                return null;
            }
        };
    }

}
